package mytest.ssw.www.myandroidproject.view;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.RelativeLayout;
import android.widget.TextView;

import mytest.ssw.www.myandroidproject.R;

/**
 * Created by 73409 on 2015/10/29.
 */
public class ClickItimView extends RelativeLayout {

    CheckBox checkBox;
    TextView contenttv,titletv;
    String truecheck;
    String falsecontent;
    boolean aBoolean=false;
    String title;
    public void initview(Context context)
    {
        View.inflate(context, R.layout.clickitem,this);
        checkBox=(CheckBox)this.findViewById(R.id.checkbox);
        contenttv=(TextView)this.findViewById(R.id.content);
        titletv=(TextView)this.findViewById(R.id.title);
    }

    public ClickItimView(Context context) {
        super(context);
    }

    public ClickItimView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initview(context);
         title = attrs.getAttributeValue("mytest.ssw.www.myandroidproject","mtitle");
         truecheck = attrs.getAttributeValue("mytest.ssw.www.myandroidproject","truecontent");
         falsecontent = attrs.getAttributeValue("mytest.ssw.www.myandroidproject","falsecontent");
         titletv.setText(title);
    }
    public boolean changecheck()
    {
        if (ischeck())
        {
            contenttv.setText(falsecontent);
            checkBox.setChecked(false);
            return false;
        }
        else
        {
            contenttv.setText(truecheck);
            checkBox.setChecked(true);
            return true;
        }
    }
    public boolean ischeck()
    {
        return checkBox.isChecked();
    }
    public void notifview(boolean check)
    {
        if (check)
        {
            contenttv.setText(truecheck);

        }
        else
        {
            contenttv.setText(falsecontent);
        }
        checkBox.setChecked(check);
    }
}
